package me.xiaoyan.ehr.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.swagger.models.auth.In;
import me.xiaoyan.ehr.mapper.JobMapper;
import me.xiaoyan.ehr.po.Job;
import me.xiaoyan.ehr.service.JobService;
import org.springframework.data.domain.PageImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.Map;

@Service
public class JobServiceImpl extends BaseService<JobMapper, Job> implements JobService {
    @Override
    public IPage<Job> selectByParams(Map<String, String> params) {
        QueryWrapper<Job> query = new QueryWrapper<>();
        query.eq("status", 1); // and status = 1
        if (StringUtils.hasLength(params.get("name"))) {
            // sql 等价于 where name like '%参数%'
            query.like("name", params.get("name"));
        }
        return selectByPage(params, query);
    }
}
